from transformers import pipeline

# 1.情感分析
# classifier = pipeline("sentiment-analysis")
# m = classifier("I've been waiting for a HuggingFace course my whole life.")
# print(m)
# 2.零样本分类
# classifier = pipeline("zero-shot-classification")
# m = classifier(
#     "This is a course about the Transformers library",
#     candidate_labels=["education", "politics", "business"],
# )
# print(m)

# 3.文本生成
# generator = pipeline("text-generation")
# t =generator("In this course, we will teach you how to")
# print(t)

# 4.文本生成，选择模型和设置参数
# generator = pipeline("text-generation", model="distilgpt2")
# t = generator(
#     "In this course, we will teach you how to",
#     max_length=30,
#     num_return_sequences=2,
# )
# print(t)

# 5.填充给定文本的空白
# unmasker = pipeline("fill-mask")
# t = unmasker("I am a novelist living in a <mask> estate.", top_k=2)
# print(t)

# 6.命名实体识别
ner = pipeline("ner", grouped_entities=True)
n = ner("My name is Sylvain and I work at Hugging Face in Brooklyn.")
print(n)

